package com.cskaoyan.servlet;

import com.cskaoyan.bean.CollectParameter;
import com.cskaoyan.bean.PageData;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.common.CommonServlet;
import com.cskaoyan.service.CollectService;
import com.cskaoyan.service.impl.CollectServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/admin/collect/*")
public class AdminCollectServlet extends CommonServlet {
    CollectService collectService = new CollectServiceImpl();

    public BaseRespVo list(HttpServletRequest request, HttpServletResponse response) throws InvocationTargetException, IllegalAccessException {
        Map<String, String[]> parameterMap = request.getParameterMap();
        CollectParameter collectParameter = new CollectParameter();
        BeanUtils.copyProperties(collectParameter, parameterMap);

        PageData pageData = collectService.list(collectParameter);

        return BaseRespVo.ok(pageData);
    }
}
